package com.hedl.practice.diyJava.multithreading.Interrupt_thread.practice.example2;

import com.hedl.practice.diyJava.multithreading.Interrupt_thread.practice.example2.entity.HelloThread;

import java.util.concurrent.TimeUnit;

/**
 * @author Big Watermelon
 * @description
 * @date 2024/02/20/09:28
 */
public class ThreadRunning {
    public static void main(String[] args) {
        HelloThread thread = new HelloThread();

        System.out.println("Main start.");

        thread.start();

        try {

            TimeUnit.MILLISECONDS.sleep(1);

        } catch (InterruptedException e) {
            e.printStackTrace();
        }finally {
            //标志位置为false,类似锁的概念,设置false就会关闭线程
            thread.running = false;

            System.out.println("Main end.");
        }
    }
}
